﻿namespace GoodAdmin.System;

public class UserAddInput:SysUser
{
    /// <summary>
    /// 账号
    /// </summary>
    [Required(ErrorMessage = "账号不能为空")]
    public override string Account { get; set; }

    /// <summary>
    /// 真实姓名
    /// </summary>
    [Required(ErrorMessage = "姓名不能为空")]
    public override string Name { get; set; }

    /// <summary>
    /// 真实姓名
    /// </summary>
    [Required(ErrorMessage = "组织不能为空")]
    public override long OrgId { get; set; }

}
public class UserUpdateInput: UserAddInput
{
    /// <summary>
    /// Id
    /// </summary>
    [Required(ErrorMessage = "Id不能为空")]
    public override long Id { get; set; }
}
public class UserDeleteInput
{

}
public class UserPageInput: BasePageInput
{
    public long? OrgId { get; set; }
    public string Gender { get; set; }
    public string Name { get; set; }
    public string Status { get; set; }
    public Expressionable<SysUser> Expression { get; set; }
}

/// <summary>
/// 授权用户角色
/// </summary>
public class UserRoleInput: BaseIdInput
{
    /// <summary>
    /// 角色Id集合
    /// </summary>
    [Required(ErrorMessage = "角色集合不能为空")]
    public List<long> RoleIdList { get; set; }
}

public class ChangePwdInput: BaseIdInput
{
    /// <summary>
    /// 新密码
    /// </summary>
    [Required(ErrorMessage = "新密码不能为空")]
    [StringLength(32, MinimumLength = 5, ErrorMessage = "密码需要大于5个字符")]
    public string PasswordNew { get; set; }
    /// <summary>
    /// 当前密码
    /// </summary>
    
    public string PasswordOld { get; set; }
}

public class UserBatchAdd
{
    /// <summary>
    /// 帐号
    /// </summary>
    [Display(Name = "*账号")]
    [Required(ErrorMessage ="账号不能为空")]
    public string Account { get; set; }

    /// <summary>
    /// 姓名
    /// </summary>
    [Display(Name = "*姓名")]
    [Required(ErrorMessage = "姓名不能为空")]
    public string Name { get; set; }

    /// <summary>
    /// 工号
    /// </summary>
    [Display(Name = "*工号")]
    [Required(ErrorMessage = "工号不能为空")]
    public string WorkId { get; set; }

    /// <summary>
    /// 性别
    /// </summary>
    [Display(Name = "性别")]
    public string Gender { get; set; }

    /// <summary>
    /// 出生日期
    /// </summary>
    [Display(Name = "出生日期")]
    public DateTime? Birthday { get; set; }

    /// <summary>
    /// 民族
    /// </summary>
    [Display(Name = "民族")]
    public string Nation { get; set; }

    /// <summary>
    /// 手机号码
    /// </summary>
    [Display(Name = "*手机号码")]
    [Required(ErrorMessage = "手机号码不能为空")]
    [DataValidation(ValidationTypes.PhoneNumber, ErrorMessage = "手机号码格式不正确")]
    public string Phone { get; set; }

    /// <summary>
    /// 证件类型
    /// </summary>
    [Display(Name = "证件类型")]
    public string CardType { get; set; }

    /// <summary>
    /// 证件号码
    /// </summary>
    [Display(Name = "证件号码")]
    public string IdCardNum { get; set; }

    /// <summary>
    /// 邮箱
    /// </summary>
    [Display(Name = "邮箱")]
    [DataValidation(ValidationTypes.EmailAddress,ErrorMessage ="邮箱格式不正确",AllowNullValue =true)]
    public string Email { get; set; }

    /// <summary>
    /// 地址
    /// </summary>
    [Display(Name = "地址")]
    public string Address { get; set; }

    /// <summary>
    /// 状态
    /// </summary>
    [Display(Name = "状态")]
    public string Status { get; set; }
    
    /// <summary>
    /// 组织名称
    /// </summary>
    [Display(Name = "组织名称")]
    [Required(ErrorMessage = "组织名称不能为空")]
    public string OrgName { get; set; }

    ///// <summary>
    ///// 职位名称
    ///// </summary>
    //[Display(Name = "职位名称")]
    //public string PosName { get; set; }

    /// <summary>
    /// 入职日期
    /// </summary>
    [Display(Name = "入职日期")]
    public DateTime? JoinDate { get; set; }
    /// <summary>
    /// 备注
    /// </summary>
    [Display(Name = "备注")]
    public string Remark { get; set; }

}

public class UserSelectorInput:BasePageInput
{
    public long OrgId { get; set; }
    public string keyword { get; set; }
}

public class SysUserMapper : IRegister
{
    public void Register(TypeAdapterConfig config)
    {
        config.ForType<UserBatchAdd,SysUser>()
            .Map(t => t.Status , o => o.Status ?? CommonConst.STATUS_ENABLE);
    }
}
